#include "gd32f4xx.h"
#include "systick.h"
#include "bsp_uart.h"
#include "delay.h"
#include <stdio.h>
#include "common.h"


int main(void)
{
		systick_config();  /* 系统滴答配置 */
		nvic_priority_group_set(NVIC_PRIGROUP_PRE4_SUB0);  /* 中断优先级分组,这里分组4:抢占16bit从0bit */
		bsp_uart_periph_init();  /* 初始化串口外设 */
		
		// 读取标志位
    int32_t boot_flag = 0;
		fmc_read_32bit_data(BOOT_FLAG_ADDR, 1, &boot_flag);
		if (boot_flag == FLAG_ENTER_APP) 
		{
        Jump_to_APP_Program();  // 跳转至APP
    }
    else 
		{
			printf("\r\n Welcome to Bootloader Program");
			printf("\r\n Author: Xie Yuan");
			printf("\r\n Version: 1.0");
			printf("\r\n\r\n");
			Main_Menu();
		}
		while(1) 
		{
			
		}
}
